package com.wly.login.common;

import lombok.AllArgsConstructor;
import lombok.Data;

/**
 * @author wly
 */
@Data
@AllArgsConstructor
public class Result<T> {

	// 状态码
	private int code;
	// 提示信息
	private String message;
	// 返回数据
	private T data;

	// 成功静态方法
	public static <T> Result<T> ok(T data) {
		return new Result<>(200, "操作成功", data);
	}

	// 错误静态方法
	public static <T> Result<T> error(String message) {
		return new Result<>(400, message, null);
	}

	public static <T> Result<T> unauthorized() {
		return new Result<>(401, "未授权", null);
	}

}